package com.fay.designPattern.oop.apiAuth;

import lombok.NoArgsConstructor;

import java.util.Map;

/**
 * @Title:
 * @Description:
 * @Author Fay Wang
 * @Date 2022/2/28 20:23
 * @Version 1.0
 */
@NoArgsConstructor
public class AuthToken {
    private static final long DEFAULT_EXPIRED_INTERVAL = 1 * 60 * 1000;
    private String token;
    private long createTime;
    private long expiredTimeInterval = DEFAULT_EXPIRED_INTERVAL;

    public AuthToken(String token, long createTime) {
        this.token = token;
        this.createTime = createTime;
    }

    public AuthToken(String token, long createTime, long expiredTimeInterval) {
        this.token = token;
        this.createTime = createTime;
        this.expiredTimeInterval = expiredTimeInterval;
    }

    public static AuthToken generate(String baseUrl, long createTime, Map<String, String> params) {
        return new AuthToken();
    }

    public String getToken() {
        return token;
    }

    public boolean isExpired() {
        return expiredTimeInterval > createTime;
    }

    public boolean match(AuthToken authToken) {
        return false;
    }
}
